import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQml 2.0
import TaoQuick 1.0
import QtQuick.Timeline 1.0

Loader{
    property int aduration: 200
    id:rootLoader
    source: "MainForm.qml"

    MouseArea{
        id:dragarea
        anchors.fill: parent
    }

    Button{
        objectName: "wizardBtn"
        id:helpbtn
        x:parent.width-width
        y:0
        z:99
        width: 50
        height: 50
        Drag.active: dragarea.drag.active
        Drag.dragType: Drag.Automatic

        MoveArea {
            anchors.fill: parent
            drag.target: helpbtn
            drag.minimumX: 0
            drag.maximumX: rootLoader.width - helpbtn.width
            drag.minimumY: 0
            drag.maximumY: rootLoader.height- helpbtn.height
            propagateComposedEvents: true
            onClicked: {
                var pRoot = rootLoader
                while (pRoot.parent !== null) {
                    pRoot = pRoot.parent
                }
                console.log("pRoot= "+pRoot)
                wizardComp.createObject(pRoot, {model: rootLoader.item.wizardModel })
            }
        }

        visible: rootLoader.item
                 && typeof (rootLoader.item.wizardModel) !== "undefined"
                 && rootLoader.item.wizardModel.count > 0
//        onClicked: {
//            var pRoot = rootLoader
//            while (pRoot.parent !== null) {
//                pRoot = pRoot.parent
//            }
//            console.log("pRoot= "+pRoot)
//            wizardComp.createObject(pRoot, {model: rootLoader.item.wizardModel })
//        }
        background: Image {
            anchors.fill: parent
            id: name
            source: imgPATH+"status/help.png"
        }
    }

    Component {
        id: wizardComp
        CusWizard {
            id: cusWizard
            anchors.fill: parent
            currentIndex: 0
            onWizardFinished: {
                destroy(cusWizard)
            }
        }
    }


}



